using Proto;

namespace sgf.server.hotfix
{
    public static class DBActorSystem
    {
        public class DBActorOnStartSystem : OnStartSystem<DBActor>
        {
            public override async Task OnStart(DBActor busActor, IContext context)
            {
                busActor._mongoClient =
                    new MongoClient(Config.GetStr("mongodb_url"), Config.GetStr("mongodb_database"));
                await Task.CompletedTask;
            }
        }

        public static async Task OnAdd(this DBActor self, IContext context)
        {
            var msg = (Other2DB_Add)context.Message;
            self._mongoClient.Insert(msg.data);
            await Task.CompletedTask;
        }
    }
}